package com.whyvent.controller;


import com.whyvent.common.lang.Result;
import com.whyvent.entity.MUser;
import com.whyvent.service.IMUserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whyvent
 * @since 2020-08-02
 */
@RestController
@RequestMapping("/user")
public class MUserController {

    @Resource
    IMUserService userService;

    @RequiresAuthentication
    @GetMapping("/get-by-id/{id}")
    public Result getById(@PathVariable("id") Long id){
        MUser user = userService.getById(id);
        return Result.success(user);
    }

    @PostMapping("/save")
    public Result save(@Validated @RequestBody MUser user){

        return Result.success(user);
    }
}
